// import jsonp from 'common/js/jsonp.js';
import axios from 'axios';
import {
  commonParams,
} from './config';

// 首页数据请求
export function getRecommend() {
  const url = '/api/getRecommend'

  const data = Object.assign({}, commonParams, {
    uin: 0,
    needNewCode: 1,
    platform: 'h5',
    _: +new Date(),
  })

  return axios.get(url, {
    params: data
  }).then((res) => {
    return Promise.resolve(res.data)
  })
}

export function getSongList(id) {
  const url = '/api/getDesc'

  const data = Object.assign({}, {
    g_tk: 5381,
    uin: 0,
    format: 'json',
    inCharset: 'utf-8',
    outCharset: 'utf-8',
    notice: 0,
    platform: 'h5',
    needNewCode: 1,
    new_format: 1,
    pic: 500,
    disstid: id,
    type: 1,
    json: 1,
    utf8: 1,
    onlysong: 0,
    nosign: 1,
    song_begin: 0,
    song_num: 30,
    _: +new Date(),
  })

  return axios.get(url, {
    params: data
  }).then((res) => {
    return Promise.resolve(res.data)
  })
}
